/**
 * Created by admin on 2018/1/26.
 */
layui.config({
    base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
    var form = layui.form(),
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;

    //创建一个编辑器
    var editIndex = layedit.build('role_content');
    var addRoleArray = [],addRole;
    form.on("submit(addRole)",function(data){
    	debugger;
    	$.ajax({
    		contentType:'application/x-www-form-urlencoded; charset=UTF-8',
            	url : "role/userAdd",
            	type : "post",
            	data : data.field,
            	dataType : "json"
    	})
//    	debugger;
//        //是否添加过信息
//        if(window.sessionStorage.getItem("addRole")){
//            addRoleArray = JSON.parse(window.sessionStorage.getItem("addRole"));
//        }
//
//
//        addRole = '{"userId":"'+$(".userId").val()+'",';  //用户ID
//        addRole += '"userName":"'+$(".userName").val()+'",'; //用户名称
//        addRole += '"pwd":"'+$(".pwd").val()+'",'; //密码
//        addRole += '"role":"'+$(".role option").eq($(".role").val()).text()+'",'; //权限
//        addRole += '"other":"'+$(".other").val()+'"}'; //备注
//        addRoleArray.unshift(JSON.parse(addRole));
//        window.sessionStorage.setItem("addRole",JSON.stringify(addRoleArray));
        //弹出loading
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        setTimeout(function(){
            top.layer.close(index);
            top.layer.msg("文章添加成功！");
            layer.closeAll("iframe");
            //刷新父页面
            parent.location.reload();
        },2000);
        return false;
    })

})